﻿
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Collections.Generic;


namespace HZ.Supervise.Web.Secondphase
{
    public partial class RecieverSelect : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindInfo();
        }

        /// <summary>
        /// 根据不同的flag绑定不同的内容
        /// </summary>
        private void BindInfo()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["flag"]))
            {
                //绑定医院
                if (Request.QueryString["flag"] == "1")
                {
                    this.lblName.Text = "医院名称：";
                    int t = 0;
                    HZ.Supervise.IBLL.IBLL_PreWarning pre = HZ.Supervise.BLLFactory.IBLL_PreWarning();
                    System.Data.DataTable dt = new System.Data.DataTable();
                    HZ.Supervise.Model.Hospital Hospital = new HZ.Supervise.Model.Hospital();
                    Hospital.HospitalName = HZ.Fun.CheckString(this.txtName.Text);

                    dt = pre.GetHospital(Hospital, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out t);
                    AspNetPager1.RecordCount = t;

                    gvwHospital.DataSource = dt;
                    gvwHospital.DataBind();
                }
                //绑定企业
                if (Request.QueryString["flag"] == "2")
                {
                    this.lblName.Text = "企业名称：";
                    int t = 0;
                    HZ.Supervise.IBLL.IBLL_PreWarning pre = HZ.Supervise.BLLFactory.IBLL_PreWarning();
                    System.Data.DataTable dt = new System.Data.DataTable();
;
                    string companyName = HZ.Fun.CheckString(this.txtName.Text);

                    dt = pre.GetCompany(companyName, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out t);
                    AspNetPager1.RecordCount = t;

                    gvwCompany.DataSource = dt;
                    gvwCompany.DataBind();
                }
                ////绑定中心机构
                if (Request.QueryString["flag"] == "3")
                {
                    this.lblName.Visible = false;
                    this.txtName.Visible = false;
                    this.btnSearch.Visible = false;
                    gvwManageOrg.Visible = true;
                    int t = 0;
                    HZ.Supervise.IBLL.IBLL_PreWarning pre = HZ.Supervise.BLLFactory.IBLL_PreWarning();
                    System.Data.DataTable dt = new System.Data.DataTable();
                    ;
                    string ManageOrgName = HZ.Fun.CheckString(this.txtName.Text);

                    dt = pre.GetManageOrg(ManageOrgName, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out t);
                    AspNetPager1.RecordCount = t;

                    //IList<ManageOrg> lstManageOrg = im.GetAllManageOrg();
                    gvwManageOrg.DataSource = dt;
                    gvwManageOrg.DataBind();
                }
                ////绑定角色列表
                //if (Request.QueryString["flag"] == "4")
                //{
                //    int totalCount;
                //    //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
                //    gvwRole.Visible = true;
                //    //IList<Role> lstRole = ir.GetAllRole(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
                //    AspNetPager1.RecordCount = totalCount;
                //    gvwRole.DataSource = lstRole;
                //    gvwRole.DataBind();
                //}
            }
        }

        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            BindInfo();
        }
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            BindInfo();
        }
    }
}
